home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWFiles / FWFileSp.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  6.5 KB  |  199 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWFileSp.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #if !defined(FWFILESP_H) && !defined(__ODFRC__)
  11. #define FWFILESP_H
  12.  
  13. #ifndef FWSOMPTR_H
  14. #include "FWSOMPtr.h"
  15. #endif
  16.  
  17. #ifndef FWEXCDEF_H
  18. #include "FWExcDef.h"
  19. #endif
  20.  
  21. #ifndef FWSTRS_H
  22. #include "FWStrs.h"  
  23. #endif
  24.  
  25. #ifndef FWSOMPTR_H
  26. #include "FWSOMPtr.h"
  27. #endif
  28.  
  29. #include "SLFileSp.xh"
  30.  
  31. #if defined(FW_BUILD_MAC) && !defined(__FILES__)
  32. #include <Files.h>
  33. #endif
  34.  
  35. //========================================================================================
  36. // Forward class declarations
  37. //========================================================================================
  38. class FW_PDirectorySpecification;
  39.  
  40.  
  41. //========================================================================================
  42. //    FW_PFileSpecification
  43. //
  44. //    This class is used to identify a disk-based file.  
  45. //========================================================================================
  46.  
  47. class FW_PFileSpecification : public FW_TSOMPtr<FW_OFileSpecification>
  48. {
  49. public:
  50.  
  51.     FW_DECLARE_AUTO(FW_PFileSpecification)
  52.     
  53.     FW_PFileSpecification(Environment *ev,
  54.                           FW_ODirectorySpecification* directory,
  55.                           const FW_CString& fileName);
  56.         // Create a file specification from a directory and a file name.  The file name
  57.         //   should include any extensions that might be necessary.
  58.         
  59.     FW_PFileSpecification(Environment *ev, const FW_CString& pathName);
  60.         // Create a file specification from a full or partial pathname.  In the case of
  61.         //   a partial pathname, the specification will use the current default
  62.         //   directory to build a full pathname.
  63.  
  64.     FW_PFileSpecification(Environment *ev, FW_OFileSpecification* specification);
  65.     FW_PFileSpecification(const FW_PFileSpecification& specificationPtr);
  66.         // Copy Constructors
  67.  
  68.     ~FW_PFileSpecification();
  69.         // Destructor
  70.  
  71.  
  72.     //===========================================================
  73.     // Operators
  74.     //===========================================================
  75.     
  76.     FW_Boolean operator==(FW_OFileSpecification* theOtherFile) const;
  77.         // Does this file represent the same file as theOtherFile.
  78.         
  79.     FW_Boolean operator!=(FW_OFileSpecification* theOtherFile) const;
  80.         // Does this file not represent the same file as theOtherFile
  81.         
  82.         
  83.     FW_PFileSpecification& operator=(const FW_PFileSpecification& theOtherFile);
  84.         // Copy all of the file information from theOtherFile so that this file spec
  85.         //   represents the same file.
  86.  
  87.     FW_PFileSpecification& operator=(const FW_CString& fileName);
  88.         // Change the name of this file to fileName.  fileName may be a partial pathName.
  89.         // This does not change any of the existing path information.
  90.  
  91.  
  92. #ifdef FW_BUILD_MAC
  93. public:
  94.     FW_PFileSpecification(Environment *ev, const FSSpec& macSpec);
  95.         // Create a file specification based on a Macintosh FSSpec.
  96.     
  97.     FW_PFileSpecification& operator=(const FSSpec& macSpec);
  98.         // This specifier will now represent the file described by macSpec.
  99.  
  100. private:
  101.     void Clone(Environment *ev, const FSSpec& macSpec);
  102. #endif
  103.  
  104. private:
  105.     void Clone(Environment *ev, FW_OFileSpecification* specification);
  106.     void Clone(Environment *ev, const FW_CString& fileName);
  107. };
  108.  
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    FW_PFileSpecification::operator!=
  112. //----------------------------------------------------------------------------------------
  113.  
  114. inline FW_Boolean FW_PFileSpecification::operator!=(FW_OFileSpecification* theOtherFile) const
  115. {
  116.     return (!(FW_PFileSpecification::operator==(theOtherFile)));
  117. }
  118.  
  119.  
  120.  
  121. //========================================================================================
  122. //    FW_PDirectorySpecification
  123. //
  124. //    This class is used to indentify a disk-based directory. A directory uses most of the
  125. //    same information as a file specification, but is not a file.
  126. //========================================================================================
  127. class FW_PDirectorySpecification : public FW_TSOMPtr<FW_ODirectorySpecification>
  128. {
  129. public:
  130.  
  131.     FW_DECLARE_AUTO(FW_PDirectorySpecification)
  132.     
  133.     FW_PDirectorySpecification();
  134.         // Specifies the current default directory
  135.         
  136.     FW_PDirectorySpecification(Environment *ev, FW_ODirectorySpecification* specification);
  137.     FW_PDirectorySpecification(const FW_PDirectorySpecification& other);
  138.         // Copy constructors
  139.         
  140.     FW_PDirectorySpecification(Environment *ev, const FW_CString& directoryName);
  141.         // Specifies the path by string.  directoryName can be either a full or 
  142.         //   partial path name.
  143.  
  144.     ~FW_PDirectorySpecification();
  145.         // Destructor
  146.     
  147.     
  148.     //===========================================================
  149.     // Operators
  150.     //===========================================================
  151.  
  152.     FW_Boolean operator==(FW_ODirectorySpecification* theOtherDir) const;
  153.         // Equality operator.
  154.     
  155.     FW_Boolean operator!=(FW_ODirectorySpecification* theOtherDir) const;
  156.         // Inequality operator.
  157.     
  158.     FW_PDirectorySpecification& operator=(const FW_PDirectorySpecification& theOtherDir);
  159.         // Assignment operator
  160.     
  161.     FW_PDirectorySpecification& operator=(const FW_CString& directoryName);
  162.         // Change the directory name to directoryName.  directoryName may be a partial
  163.         //   path name.
  164.         
  165.     FW_PDirectorySpecification& operator+=(const FW_CString& directoryName);
  166.         // Add directoryName to the end of this path.  This routine will add a path
  167.         //   separator so that the user does not need to.  The remaining path information
  168.         //   may specify a subdirectory or parent directory, but must start from this
  169.         //   directory.
  170.         
  171. #ifdef FW_BUILD_MAC
  172. public:
  173.     FW_PDirectorySpecification(Environment *ev, const FSSpec& macSpec);
  174.         // Create a directory spec from a Macintosh FSSpec.
  175.         
  176.     FW_PDirectorySpecification& operator=(const FSSpec& macSpec);
  177.         // Assignment operator for a Macintosh spec.
  178. private:
  179.     void Clone(Environment *ev, const FSSpec& macSpec);
  180. #endif
  181.  
  182. private:
  183.     void Clone(Environment *ev, FW_ODirectorySpecification* specification);
  184.     void Clone(Environment *ev, const FW_CString& fileName);
  185. };
  186.  
  187.  
  188. //----------------------------------------------------------------------------------------
  189. //    FW_PDirectorySpecification::operator!=
  190. //----------------------------------------------------------------------------------------
  191. inline FW_Boolean FW_PDirectorySpecification::operator!=(FW_ODirectorySpecification* theOtherDir) const
  192. {
  193.     return (!(FW_PDirectorySpecification::operator==(theOtherDir)));
  194. }
  195.  
  196. #endif
  197.  
  198.  
  199.